<template>
  <div v-for="(item, index) in data" :key="item">
    <div
      class="py-[8px]"
      :class="{ side_top: index > 0 }"
      v-if="item?.sub?.length"
    >
      <div class="mb-[8px]">{{ item.name }}</div>
      <div class="flex flex-wrap gap-[8px]">
        <div v-for="it in item.sub" :key="it" class="content">
          <span @click="handleEdit(it)"
            >{{ it.title }}(<span class="text-[#E50113]">{{ it.count }}</span
            >)</span
          >
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { dealParams } from "./data";
const router = useRouter();
const props = defineProps({
  data: {
    type: Array,
    default: () => [],
  },
});
const { data } = toRefs(props);

const handleEdit = (val) => {
  if (val?.param) {
    let obj = dealParams(val.param);
    console.log(obj);
    sessionStorage.setItem("_table_form", JSON.stringify({ tableForm: obj }));
  }

  router.push(val?.url);
};
</script>
<style lang="scss" scoped>
.side_top {
  // border-top: 1px dashed #c3dbff;
  border-top: 1px dashed var(--base-border-color);
}
.content {
  position: relative;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(52, 135, 255, 0.12);
  // background: #f6faff;
  background-color: var(--base-table-header-bg-color);
  cursor: pointer;
  font-size: 14px;
  // color: #333333;
  &:hover {
    // opacity: 0.8;
    background-color: var(--base-table-row-hover-bg-color);
  }
}
</style>
